package com.example.jobback.controller.manager;

import com.example.jobback.req.common.password.ResetPasswordReq;
import com.example.jobback.req.manager.profile.ManagerReq;
import com.example.jobback.resp.manager.profile.ManagerResp;
import com.example.jobback.result.Result;
import com.example.jobback.service.manager.ManagerProfileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName: ManagerProfileController
 * @Description:管理员-个人中心控制器
 * @Author: lhb
 * @Date: 2025/6/21
 */
@RestController
@RequestMapping("/manager/profile")
@Tag(name = "管理员-个人中心控制器",description = "管理员个人中心服务的相关接口")
public class ManagerProfileController {
    private final ManagerProfileService managerProfileService;

    public ManagerProfileController(ManagerProfileService managerProfileService) {
        this.managerProfileService = managerProfileService;
    }

    @Operation(summary = "获取基本信息",description = "无参数")
    @GetMapping("/getBasicMessage")
    @ApiResponse(description = "返回管理员响应体")
    public Result<ManagerResp> getBasicMessage(){
        return managerProfileService.getBasicMessage();
    }



    @Operation(summary = "编辑基本信息",description = "前端交接记得json化")
    @ApiResponse(description = "返回token，前端更新token")
    @PostMapping("/editBasicMessage")
    public Result<Object> editBasicMessage(@Validated
                                           @RequestBody
                                           ManagerReq req){
        return managerProfileService.editBasicMessage(req);
    }

    @Operation(summary = "上传头像",description = "上传头像，这里的file是MultipartFile类")
    @PostMapping("/uploadAvatar")
    @ApiResponse(description = "返回token，前端更新token，重新执行getBasicMessage")
    public Result<Object> uploadAvatar(@RequestBody
                                       @Parameter(description = "头像文件", required = true)
                                       MultipartFile file){
        return managerProfileService.uploadAvatar(file);
    }
}
